<template>
  <div class="line-container">
    <div class="title">
      <p>最近7天利润趋势图</p>
      <img src="../images/dataScreen-title.png" alt="" />
    </div>
    <div ref="chartContainer" class="chartContainer"></div>
  </div>
</template>

<script setup lang="ts">
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'
let chartContainer = ref()
const option = {
  title: {
    text: '最近7天利润趋势图',
    textStyle: {
      color: 'red',
    },
  },
  xAxis: {
    type: 'category',
    boundaryGap: false,
    data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
    splitLine: {
      show: false,
    },
  },
  yAxis: {
    axisLine: {
      show: true,
    },
    splitLine: {
      show: false,
    },
  },
  grid: {
    left: '40px',
    bottom: '40px',
    right: 0,
    top: 0,
  },
  series: [
    {
      type: 'line',
      data: [120, 240, 560, 380, 652, 770, 685],
      smooth: true,
      emphasis: {
        disabled: false,
      },
      areaStyle: {
        color: {
          type: 'linear',
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          colorStops: [
            {
              offset: 0,
              color: 'red', // 0% 处的颜色
            },
            {
              offset: 1,
              color: 'blue', // 100% 处的颜色
            },
          ],
          global: false, // 缺省为 false
        },
      },
    },
  ],
}
onMounted(() => {
  let myChart = echarts.init(chartContainer.value)
  myChart.setOption(option)
})
</script>

<style lang="scss" scoped>
.line-container {
  margin: 0 20px;
  width: 100%;
  height: 100%;
  background: url('../images/dataScreen-main-cb.png') no-repeat;
  background-size: 100% 100%;
  .title {
    padding-left: 20px;
    p {
      color: #fff;
    }
  }
  .chartContainer {
    height: calc(100% - 40px);
  }
}
</style>
